<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			window.onload = function(){
				//创建ul
				var newUl = document.createElement("ul");
				//创建li
				var newLi = document.createElement("li");
				var newLi2 = document.createElement("li");
				var newLi3 = document.createElement("li");
				//把ul放入div,li放入ul
				div1.appendChild(newUl);
				newUl.appendChild(newLi);
				newUl.appendChild(newLi2);
				newUl.appendChild(newLi3);
				//创建元素
				var newText = document.createTextNode("奔驰");
				var newText2 = document.createTextNode("宝马");
				var newText3 = document.createTextNode("五菱宏光");
				//插入元素到li中
				newLi.appendChild(newText);
				newLi2.appendChild(newText2);
				newLi3.appendChild(newText3);
				//替换
				var par = document.getElementsByTagName("li")[0];
				var chil = par.firstChild;
				console.log(chil);
				chil.nodeValue = "悍马";
				
				
			}
		</script>
	</head>
	<body>
		<div id="div1">
			
		</div>
	</body>
</html>
